import { Component, OnInit, Input, Injector } from '@angular/core';
import { RecruitmentPlanMgeSvrService } from '../../../services/recruitment-plan-mge-svr.service';
import { ResumeMgeSvr } from '../../../services/resume-mge-svr.service';
import { RecruitmentPlan } from '../../../domains/recruitmentplan.domain';
import { Resume } from '../../../domains/resume.domain';
import { CoreComponent } from 'pengesoft-ng-lib';
import { JobServiceSvr } from '../../../services/job.service';
@Component({
  selector: 'app-recruitment-management',
  templateUrl: './recruitment-management.component.html',
  styleUrls: ['./recruitment-management.component.less']
})
export class RecruitmentManagementComponent extends CoreComponent implements OnInit {
  @Input() info: any;          // 接收招聘信息
  allJobs = [];
  recuInfoList: any;
  resumeInfoList: any;
  constructor(
    private injector: Injector,
    public jobServiceSvr: JobServiceSvr,
    public recruSrv: RecruitmentPlanMgeSvrService,
    public resumeSvr: ResumeMgeSvr) {
    super(injector);
  }

  ngOnInit(): void {
  }

  // 拿到申请列表
  getRecruList(): void {
    this.recruSrv.getDetailList(new RecruitmentPlan()).then(res => {
      this.recuInfoList = res;
      this.info = res;
      // tslint:disable-next-line:no-unused-expression
    }, err => {
      this.nzMessageSvr.error(err.Msg);
    });

  }

  // 拿到候选人列表
  getRrsumeList(n): void {
    this.jobServiceSvr.getAllJob().then(res => {
      this.allJobs = res.map(item => {
        return {
          label: item.JobName,
          value: item.Id,
        };
      });
      // tslint:disable-next-line: no-shadowed-variable
      this.resumeSvr.getDetailList(new Resume()).then(res => {
        this.resumeInfoList = res.filter(item => {
          return item.Resume.ApplyStatus === n;
        });
      }, err => {
        this.nzMessageSvr.error(err.Msg);
      });
    }, err => {
      this.nzMessageSvr.error(err.Msg);
    });
  }
}
